﻿using System;
using System.Reflection;

namespace TC
{
    public abstract class Port : ISerialize
    {
        public string name;
        public FlowNode parent;
        
        public Port(FlowNode parent, string name)
        {
            this.parent = parent;
            this.name = name;
        }
        
        public virtual bool IsInput { get; } = true;
        public virtual bool AllowMultiConnect { get; } = false;

        public abstract Type type { get; }
        public abstract bool CanConnect(Port other);
        public abstract bool CanConnect(Type nodeType, out FieldInfo portInfo);
        
        public virtual void OnSerialize_t(ISerializeEntity entity)
        {   
        }

        public virtual void OnDeserialize_t(ISerializeEntity entity)
        {
        }

        public virtual ISerializeEntity CreateEntity()
        {
            return null;
        }
    }
    
    public abstract class FlowPort : Port
    {
        public FlowPort(FlowNode parent, string name) : base(parent, name)
        {
        }
    }
    
    public abstract class ValuePort : Port
    {
        public ValuePort(FlowNode parent, string name) : base(parent, name)
        {
        }
    }
}